/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package DAO;

import DAOInterface.DAODatasetConnection;
import java.io.*;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author Fabian
 */
public class DatasetConnection implements DAODatasetConnection {

    File DatasetFile;
    FileReader    fileR;
    BufferedReader bufferR;

    /**
     * 
     * @param nameDataset
     * @return
     */
    @Override
    public boolean setConnection(String nameDataset) {
        try {
            DatasetFile = new File(nameDataset);
            fileR = new FileReader(DatasetFile);
            bufferR = new BufferedReader(fileR);
            
            return true;
        } catch (Exception ex) {
            return false;
        }
    }

    /**
     * 
     * @return
     */
    @Override
    public String getLine() {
        try {
            return bufferR.readLine();
        } catch (IOException ex) {
            Logger.getLogger(DatasetConnection.class.getName()).log(Level.SEVERE, null, ex);
            return "finFile";
        }
    }

    /**
     * 
     * @return
     */
    @Override
    public String getHeader() {
        try {
            fileR = new FileReader(DatasetFile);
            bufferR = new BufferedReader(fileR);
            return bufferR.readLine();
        } catch (IOException ex) {
            Logger.getLogger(DatasetConnection.class.getName()).log(Level.SEVERE, null, ex);
            return "";
        }
    }
}
